1 /** 2 The db_exceptions module contains: 3 $(TOC UniqueConstraintException) 4 $(TOC KeyedException) 5 $(TOC CheckConstraintException) 6 $(TOC ForeignKeyException) 7 $(TOC ExclusionConstraintException) 8 9 License: $(GPL2) 10 11 Authors: Matthew Armbruster 12 13 $(B Source:) $(SRC $(SRCFILENAME)) 14 15 Copyright: 2016 16 */ 17 module db_constraints.db_exceptions; 18 19 /** 20 Exception thrown on unique constraint violations. 21 */ 22 class UniqueConstraintException : Exception 23 { 24 /** 25 Params: 26 msg = the message thrown with the unique constraint violation 27 file = the file where the exception occurred 28 line = the line number where the exception occurred 29 next = references the exception that was being handled when this one was generated 30 */ 31 this(string msg, string file = __FILE__, size_t line = __LINE__, 32 Throwable next = null) 33 { 34 super("Unique constraint violation. " ~ msg, file, line, next); 35 } 36 } 37 /** 38 Exception thrown on errors involved with keyed items. 39 */ 40 class KeyedException : Exception 41 { 42 /** 43 Params: 44 msg = the message thrown 45 file = the file where the exception occurred 46 line = the line number where the exception occurred 47 next = references the exception that was being handled when this one was generated 48 */ 49 this(string msg, string file = __FILE__, size_t line = __LINE__, 50 Throwable next = null) 51 { 52 super(msg, file, line, next); 53 } 54 } 55 56 /** 57 Exception thrown on check constraint violations. 58 */ 59 class CheckConstraintException : Exception 60 { 61 /** 62 Params: 63 msg = the message thrown with the check constraint violation 64 file = the file where the exception occurred 65 line = the line number where the exception occurred 66 next = references the exception that was being handled when this one was generated 67 */ 68 this(string msg, string file = __FILE__, size_t line = __LINE__, 69 Throwable next = null) 70 { 71 super("Check constraint violation. " ~ msg, file, line, next); 72 } 73 } 74 75 /** 76 Exception thrown on foreign key violations. 77 */ 78 class ForeignKeyException : Exception 79 { 80 /** 81 Params: 82 msg = the message thrown with the foreign key violation 83 file = the file where the exception occurred 84 line = the line number where the exception occurred 85 next = references the exception that was being handled when this one was generated 86 */ 87 this(string msg, string file = __FILE__, size_t line = __LINE__, 88 Throwable next = null) 89 { 90 super("Foreign key exception. " ~ msg, file, line, next); 91 } 92 } 93 94 /** 95 Exception thrown on exclusion constraint violations. 96 97 Version: \>=0.0.7 98 */ 99 class ExclusionConstraintException : Exception 100 { 101 /** 102 Params: 103 msg = the message thrown with the exclusion constraint violation 104 file = the file where the exception occurred 105 line = the line number where the exception occurred 106 next = references the exception that was being handled when this one was generated 107 */ 108 this(string msg, string file = __FILE__, size_t line = __LINE__, 109 Throwable next = null) 110 { 111 super("Exclusion constraint violation. " ~ msg, file, line, next); 112 } 113 }